package com.yue.ssa.controller;

import com.yue.ssa.bean.Menu;
import com.yue.ssa.bean.RespBean;
import com.yue.ssa.service.RoleMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "角色资源映射管理", tags = "角色资源映射管理")
@RestController
@RequestMapping("rest/roleMenu")
public class RoleMenuController {

    @Autowired
    private RoleMenuService roleMenuService;

    @PreAuthorize("hasAuthority('system_role::write')")
    @ApiOperation(value = "分配资源", notes = "分配资源")
    @PostMapping("/assignMenus")
    public RespBean assignMenus(@RequestParam String rid, @RequestBody List<Menu> menuList) {
        return roleMenuService.assignMenus(rid, menuList);
    }
}
